package com.snow.useviewdemo.qiniuplay;

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.WindowManager;

import com.snow.common.base.BaseBasesActivity;
import com.snow.useviewdemo.R;
import com.snow.useviewdemo.qiniuplay.video.PlayOnceStateListener;
import com.snow.useviewdemo.qiniuplay.video.PlayOnceVideoManager;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : zyt
 * e-mail : 632105276@qq.com
 * date   : 2019-06-10
 * desc   :横 全屏 播放视频
 */
public class QPLFullPlayVideoAct extends BaseBasesActivity {

    @BindView(R.id.fvpcv_view)
    QPLBaseQPLVideoPlayView fvpcvView;

    public static final String TEST_VIDEO = "https://cdn.changguwen.com/cms/media/20181024/0dbfb433-d976-4c54-9026-272ca2967f46-1540367091203-sd.mp4";


    @Override
    protected void initView() {
        //设置全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //禁止屏幕休眠
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        String videoCover = getIntent().getStringExtra("videoCover");
        String videoUrl = getIntent().getStringExtra("videoUrl");
        String videoName = getIntent().getStringExtra("videoName");
//        fvpcvView.setVideoInfo(videoName, videoCover);
        PlayOnceVideoManager.init().playVideo(TEST_VIDEO);
        PlayOnceVideoManager.init().setPlayStateListener(new PlayOnceStateListener() {
            @Override
            public void bufferAndProgress(int percent) {

            }

            @Override
            public void playComplement() {

            }

            @Override
            public void playProgress(long currentPlayTime) {

            }

            @Override
            public void startPlayMusic() {
                fvpcvView.setSurfaceTexture();
            }

            @Override
            public void againPlay() {

            }
        });
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        PlayOnceVideoManager.init().stop();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.act_full_play_video;
    }
}
